package com.expmle.surfaceviewdemo

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)


        start_btn.setOnClickListener {
            if (!mLuckyPan.isStart()) {

//private val mStrs = arrayOf("单反相机", "IPAD", "恭喜发财", "IPHONE", "服装一套", "恭喜发财")

                val number = (Math.random() * 100).toInt()
                println("MainActivity.onCreate number=" + number)
                if (number > 0 && number < 10) {
                    mLuckyPan.luckyStart(4);
                }
                if (number >= 10 && number < 50) {
                    mLuckyPan.luckyStart(2);
                }
                if (number >= 50 && number < 95) {
                    mLuckyPan.luckyStart(5);
                }
                if (number >= 95 && number < 100) {
                    mLuckyPan.luckyStart(0);
                }



                start_btn.setImageResource(R.mipmap.stop)
            } else {
                if (!mLuckyPan.isShouldEnd()) {
                    mLuckyPan.luckyEnd();
                    start_btn.setImageResource(R.mipmap.start)
                }
            }
        }
    }
}
